<?php
if(!class_exists("sthook_1_0")) {
	class sthook_1_0{
            public $option = '';
                public function __construct($config)
		{
                    $this->config = $config;
                    $this->config ['pluginDir'] = WP_PLUGIN_DIR . '/' . $config ['plugin_name'] . '/';
                    $this->option = get_option($this->config['plugin_name'].'_'.$this->config['option_key'].'_settings');
                    $this->hookManage();
                    $this->hookCustom();
		}

                public function loadmodel($modelName) {
			$className = $modelName . "_model";
			$fileName = $this->config ['pluginDir'] . "models/{$modelName}.php";
			require_once $fileName;
			$obj = new $className($this->config);
			return $obj;
		}

                public function hookManage(){

                    $method = array($this, 'loadTextdomain' );
                    add_action('init', $method);
                    $method = array($this, 'languageStart' );
                    add_filter('load_textdomain_mofile', $method, 100, 2);

                    $method = array($this, 'includeExtraPlugin');
                    add_action( $this->config['plugin_name'].'_extra_contruction', $method);

                    $method = array($this, 'actionTitle');
                    add_filter('wp_title', $method, 100, 3);
                }

                public function hookCustom(){
                    //
                }

                public function includeExtraPlugin() {
                    // default process here
                }

                //Initialize hook function
                public function loadTextdomain(){
                    load_plugin_textdomain( $this->config['plugin_name'], false, $this->config['plugin_name'].'/languages' );
                }

                public function languageStart($mofile, $domain) {
                    global $locale;

                    //$fbcontent_settings = get_option('fbcontent_settings');
                    $language = $this->option['st_language'];

                    if($domain == $this->config['plugin_name']){
                        $mofile = str_replace($locale, $language, $mofile);
                        return $mofile;
                    }
                    return $mofile;
                }

                /**
                 * Prints title of action page.
                 *
                 * @since PluginExpert 1.0
                 */
                public function actionTitle($title, $sep, $seplocation) {
                    //bloginfo('name');
                    if($title == '' )
                        $title = get_bloginfo ('name');
                    return $title;
                }

	}
}
?>